﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iOak.Data.Campaigns;
using iOak.Domain.Campaigns;

namespace iOak.Business.Campaigns
{
    public class PolicyService
    {
        private PolicyRepository _policyRepository;
        public PolicyService()
        {
            _policyRepository = new PolicyRepository("master");
        }

        public void Create(Policy policy)
        {
            _policyRepository.Create(policy);
        }

        public Policy Retrieve(Guid policyId)
        {
            return _policyRepository.Retrieve(policyId);
        }

        public void Update(Policy policy)
        {
            _policyRepository.Update(policy);
        }

        public void Delete(Guid policyId)
        {
            var policy = _policyRepository.Retrieve(policyId);

            if (policy != null)
                _policyRepository.Delete(policyId);
        }

        public List<Policy> LoadAll()
        {
            return _policyRepository.LoadAll();
        }

        //检索
        public List<Policy> FindPolicies(String subject, String keyWord) 
        {
            return _policyRepository.FindPolicies(subject, keyWord);
        }
    }
}
